Trigonometric functions are generally defined for the relatively small angular range of 0-360°, or 0-2π radians. For angular values above 2π, the values of the trigonometric functions repeat. Indeed, one could restrict the range to 0-π/2, because various trigonometric identities can be used to derive values for trigonometric functions of any angle between π/2 and 2π from trigonometric functions of angles between 0 and π/2.
One method that may be used in integrated circuit devices for calculating trigonometric functions is the CORDIC algorithm, which uses the following three recurrence equations:xn+1=xn−dnyn2−n yn+1=yn+dnxn2−n zn+1=zn−dn tan−1(2−n)For example, to calculate a sine or cosine of an input, the x value is initialized to “1”, the y value is initialized to “0”, and the Z value is initialized to the angle required. Z is then rotated towards zero, which determines the sign of dn, which is ±1—if zn is positive, then so is dn, as the goal is to bring z closer to 0; if zn is negative, then so is dn, for the same reason. x and y represent the x and y components of a unit vector; as z rotates, so does that vector, and when z has reached its final rotation to 0, the values of x and y will have converged to the cosine and sine, respectively, of the input angle.
To account for stretching of the unit vector during rotation, a scaling factor is applied to the initial value of x. The scaling factor is:
            ∏              n        =        0            ∞        ⁢                  ⁢                  1        +                  2                                    -              2                        ⁢            n                                =      1.64676025812106564    ⁢                  ⁢    …  The initial x is therefore be set to 1/1.64677 . . .=0.607252935 . . . .
However, CORDIC may become inaccurate as the inputs become small. For example, the actual value of sin(θ) approaches θ as θ approaches 0 (and therefore sin(θ) approaches 0), and the actual value of cos(θ) approaches 1 as θ approaches 0. However, the magnitude of the error between the calculated and actual values increases as e decreases.
Moreover, while CORDIC on initial consideration appears to be easily implemented in integrated circuit devices such as FPGAs, closer analysis shows inefficiencies, at least in part because of multiple, deep arithmetic structures, with each level containing a wide adder. Common FPGA architectures may have 4-6 input functions, followed by a dedicated ripple carry adder, followed by a register. When used for calculating floating point functions, such as the case of single precision sine or cosine functions, the number of hardware resources required to generate an accurate result for smaller input values can become large. Double precision functions can increase the required resources even further.